import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import AutoImport from 'unplugin-auto-import/vite'
import components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Icons from 'unplugin-icons/vite'             // 导入icon相关插件
import IconsResolver from 'unplugin-icons/resolver' // 导入icon相关插件

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({resolvers: [
        ElementPlusResolver(),
        IconsResolver({
          prefix: 'Icon',
        }),
      ],
    }),
    components({
      resolvers: [
        ElementPlusResolver(),
        IconsResolver({
          enabledCollections: ['ep']
        }),
      ]
    }),
    Icons({
      autoInstall: true,
    }),
  ],
  resolve: {
    alias: {
      // 解析当前目录下的 src 文件夹作为项目的根目录
      "@": resolve(__dirname, "./src"),
    },
    extensions: [".js", ".json", ".ts"], //忽略解析文件的后缀名，如果不写，默认是 ['.js']
  },
  server: {
    port: 8009,
    host:"localhost",
    // 设置当前页面是否打开
    open: true,

    // @ts-ignore
    hot:true
  }
  //项目主路径的别名配置，如果是相对路径，则需要配置base，如果是绝对
});
